package com.lancoo.znbkxx.teacher.aibkGenerateTestPaper.aibkGenerateDialog

import android.app.Dialog
import android.content.Context
import android.os.Bundle
import android.view.Gravity
import android.view.View
import com.lancoo.znbkxx.teacher.R
import kotlinx.android.synthetic.main.aibk_dialog_generate_testpaper_progress.*

/**
 * auther: 王国龙
 *  Date：2020.06.28
 * describe:答题暂停
 */
class DialogGenerateTestpaperProgress(
        context: Context?
) : Dialog(context!!, R.style.CustomDialog) {
    /**
     * 提交按钮
     */
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.aibk_dialog_generate_testpaper_progress)
        window!!.setGravity(Gravity.CENTER) //设置弹窗右对齐
        window!!.setWindowAnimations(R.style.MyDialogScale) //设置动画效果

        //按空白处不能取消动画
        setCanceledOnTouchOutside(false)
        //初始化界面数据
        refreshView()
    }

    /**
     * 初始化界面控件的显示数据
     */
    private fun refreshView() {
        //继续按钮
        BtnGiveUp.setOnClickListener {
            dismiss()
            clickDialogListener!!.onClickGiveUp()
        }
    }

    private var clickDialogListener: OnClickDialogListener? = null

    /*
   * 设置答题卡题号点击事件
   * */
    interface OnClickDialogListener {
        fun onClickGiveUp()//放弃组卷
    }

    fun setClickDialogListener(clickDialogListener: OnClickDialogListener?) {
        this.clickDialogListener = clickDialogListener
    }

    fun showGenerateProgressMessage(progress:String){
        ProgressBar.progress = progress.toInt()
        TvAAA.text = "$progress%"
        TvAAA.visibility = View.GONE
    }
}